from byhh.settings import DOMAIN, ARTICLE_LIST_ADDR
from byhh.utils.validation import BoardNameValidator

def make_article_list_url(board, start=None):
    '''
    Make the url for article list page.
    Parameters:
      - board(required): The board name. Available value is in byhh.settings.BOARD_LIST.
      - start(optional): The start article id in the page. Begin at 1.
    Return:
      - url(string)
    '''
    if not board or not BoardNameValidator.verify(board):
        return None

    if start:
        start = int(start)
        return "%s%s?board=%s&start=%d" % (DOMAIN, ARTICLE_LIST_ADDR, board, start)
    else: 
        return "%s%s?board=%s" % (DOMAIN, ARTICLE_LIST_ADDR, board)


